package com.yun.zf.admin.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yun.zf.admin.mapper.SysUserOrderMapper;
import com.yun.zf.admin.service.SysUserOrderService;
import com.yun.zf.admin.service.ZfOrderService;
import com.yun.zf.common.admin.domain.SysUserOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

/**
 * <p>
 * 用户订单合同关系表 服务实现类
 * </p>
 *
 * @author cj
 * @since 2021-08-18
 */
@Service
public class SysUserOrderServiceImpl extends ServiceImpl<SysUserOrderMapper, SysUserOrder> implements SysUserOrderService {
    @Autowired
    private ZfOrderService orderService;

    @Override
    @Transactional
    public int createUserOrder(Long userId, Long subOrderId, Long prov, Long cityCode, Long orderId) {
        // 发送用户订单
        SysUserOrder userOrder = new SysUserOrder();
        userOrder.setSubOrderId(subOrderId);
        userOrder.setUserId(userId);
        userOrder.setProvinceCode(prov);
        userOrder.setCityCode(cityCode);
        userOrder.setOrderId(orderId);
        userOrder.setCreateTime(new Date());
        int c = baseMapper.insert(userOrder);
        // 推送数据进入es
        orderService.getOrderEs(orderId, prov, cityCode);
        return c;
    }

}
